local lockKey = ARGV[1]
local lockTime = ARGV[2]
local nonce = ARGV[3]

local result = redis.call('get', lockKey)
if result ~= nonce then
    redis.call('set', lockKey, nonce, "EX", lockTime)
    return 1
end
return 0